<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  
  
<html xmlns="http://www.w3.org/1999/xhtml"  
    xmlns:ui="http://java.sun.com/jsf/facelets"  
    xmlns:h="http://java.sun.com/jsf/html"  
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<title>Listar usuários</title>
</h:head>
 
<h:body style="FONT-SIZE: small; FONT-FAMILY: 'Calibri';"> 
	<h:form id="edit"> 	
 		<h:dataTable value="#{userBean.listAllUsers()}" var="user" border="1" width="500px">
 			<f:facet name="header">
 				<div align="left"> 
 			    Seja bem vindo :<h:outputLabel value="#{loginUserBean.user.name}" />
 			    </div>
 			    Listagem de usuários -
 				<h:commandLink value="Atualizar" action="#{userBean.listUsers()}" /> / 
 				<h:commandLink value="Cadastrar usuário" action="#{userBean.registerUser()}"/> / 
 			 	<h:commandLink value="Pagina de controle" action="#{userBean.controlPanel()}"/>
 			</f:facet>
 			<h:column>
				<f:facet name="header">Nome:</f:facet>
				#{user.name}
 			</h:column>
 			<h:column>
				<f:facet name="header">Email:</f:facet>
				#{user.email}
 			</h:column>
 			<h:column>
				<f:facet name="header">Administrador:</f:facet>
				#{user.admin ? 'Sim' : 'Não'}
 			</h:column>
 			<h:column>
				<f:facet name="header">Sexo:</f:facet>
				#{user.sex == 'M' ? 'Masculino' : 'Feminino'}
 			</h:column>		
 			<h:column rowHeader="2" >
				<f:facet name="header" >Ações</f:facet> 
				
				<div align="center">
					<h:commandLink value="Editar" action="#{userBean.editUser()}">
						<f:setPropertyActionListener target="#{userBean.user}" value="#{user}"></f:setPropertyActionListener>
					</h:commandLink>
	
					<h:outputText value=" " />
					
					<h:commandLink value="Excluir" action="#{userBean.deleteUser()}">
						<f:setPropertyActionListener target="#{userBean.user}" value="#{user}"></f:setPropertyActionListener>
					</h:commandLink>
				</div>
 			</h:column>
 		</h:dataTable> 
 		<h:messages errorStyle="color: red; border:1" style="color: red; border:1"/>
 	</h:form> 	
</h:body> 
</html>
